class Solution
{
public:
    ListNode* deleteDuplicates(ListNode* head)
    {
        if (head == nullptr) return nullptr;

        ListNode* cur = head;
        while (cur->next)
        {
            if (cur->next->val == cur->val)
                cur->next = cur->next->next;
            else
                cur = cur->next;
        }
        return head;
    }
};